package com.hw.weathershow.util;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Cejay1314
 * @version 1.0
 * @create 2022/12/4 21:18
 */
public class StringUtil {
    private static StringUtil target;
    Gson gson;

    public StringUtil(){
        gson = new Gson();
    }
    public static StringUtil getInstance(){
        if(target==null) target = new StringUtil();
        return target;
    }
    public Map<String,Object> stringTransformIntoMap(String body){
        Map<String, Object> map = new HashMap<String, Object>();
        map = gson.fromJson(body, map.getClass());
        return map;
    }
    public Map<String,String> stringTransformIntoMapString(String body){
        Map<String, String> map = new HashMap<String, String>();
        map = gson.fromJson(body, map.getClass());
        return map;
    }
}
